========
========
filepath = "~/Desktop/Arctic/Utqiagvik/Analysis_Ready_Data/Daily/" # where daily avg data are located
exportpath = "/Users/emvanmetre/Desktop/Arctic/Utqiagvik/elizabeth seasonal analysis/PCA/" # where to export pdf files (if pdf is true)
years = c("2022", "2023", "2024")
seasons = c("Spring", "Summer", "Fall")
sites = c("TNHA", "BEO", "SSMH")
# put season values for the season that has the start of the data
date_start = "2022-06-01" # data starts in June 2022 (YEAR-MO-DY) where day is always 01
# put season values for the season that has the last of the data
date_end = "2024-11-01" # data ends after November of 2023 (will get data up UNTIL date_end not after)
monthly = T # pick T for monthly or F for seasonally
scree = F # scree plot
eigen = T # eigenvectors and eigenvalues
pdf = F # export plots to pdf (in the export path specified above)
spring_months = c("March", "April", "May")
summer_months = c("June","July","August")
fall_months = c("September", "October", "November")
winter_months = c("December", "January", "February")
spring_dates = data.frame(months=spring_months, start=c("-03-01","-04-01","-05-01"), end=c("-04-01","-05-01","-06-01"))
summer_dates = data.frame(months=summer_months, start=c("-06-01","-07-01","-08-01"), end=c("-07-01","-08-01","-09-01"))
fall_dates = data.frame(months=fall_months, start=c("-09-01","-10-01","-11-01"), end=c("-10-01","-11-01","-12-01"))
winter_dates = data.frame(months=winter_months, start=c("-12-01","-01-01","-02-01"), end=c("-01-01","-02-01","-03-01"))
if (monthly) {
all_dates = data.frame(matrix(nrow = 0, ncol = 4)) # 4 columns for month and season
} else {
all_dates = data.frame(matrix(nrow = 0, ncol = 3)) # 3 columns for season
}
for(yur in years){
# spring
if("Spring" %in% seasons){
if (monthly) {
for(i in c(1:3)){
curdate = as.Date(paste0(yur, spring_dates[i, 2]))
if(curdate >= date_start && curdate < date_end){
all_dates <- rbind(all_dates, c(spring_dates[i,1], paste0(yur, spring_dates[i, 2]),
paste0(yur, spring_dates[i, 3]),"Spring"))
}
}
}
else {
curdate = as.Date(paste0(yur, spring_dates[1, 2]))
if(curdate >= date_start && curdate < date_end){
all_dates <- rbind(all_dates, c("Spring", paste0(yur, spring_dates[1, 2]), paste0(yur, spring_dates[3, 3])))
}
}
}
if("Summer" %in% seasons){
if (monthly) {
for(i in c(1:3)){
curdate = as.Date(paste0(yur, summer_dates[i, 2]))
if(curdate >= date_start && curdate < date_end){
all_dates <- rbind(all_dates, c(summer_dates[i,1], paste0(yur, summer_dates[i, 2]),
paste0(yur, summer_dates[i, 3]),"Summer"))
}
}
} else {
curdate = as.Date(paste0(yur, summer_dates[1, 2]))
if(curdate >= date_start && curdate < date_end){
all_dates <- rbind(all_dates, c("Summer", paste0(yur, summer_dates[1, 2]),
paste0(yur, summer_dates[3, 3])))
}
}
}
if("Fall" %in% seasons){
if (monthly) {
for(i in c(1:3)){
curdate = as.Date(paste0(yur, fall_dates[i, 2]))
if(curdate >= date_start && curdate < date_end){
all_dates <- rbind(all_dates, c(fall_dates[i,1], paste0(yur, fall_dates[i, 2]),
paste0(yur, fall_dates[i, 3]),"Fall"))
}
}
} else {
curdate = as.Date(paste0(yur, fall_dates[1, 2]))
if(curdate >= date_start && curdate < date_end){
all_dates <- rbind(all_dates, c("Fall", paste0(yur, fall_dates[1, 2]),
paste0(yur, fall_dates[3, 3])))
}
}
}
if("Winter" %in% seasons){
if (monthly) {
for(i in c(1:3)){
curdate = as.Date(paste0(yur, winter_dates[i, 2]))
if(curdate >= date_start && curdate < date_end){
all_dates <- rbind(all_dates, c(winter_dates[i,1], paste0(yur, winter_dates[i, 2]),
paste0(yur, winter_dates[i, 3]),"Winter"))
}
}
} else {
curdate = as.Date(paste0(yur, winter_dates[1, 2]))
if(curdate >= date_start && curdate < date_end){
all_dates <- rbind(all_dates, c("Winter", paste0(yur, winter_dates[1, 2]),
paste0(yur, winter_dates[3, 3])))
}
}
}
}
if (monthly) {
colnames(all_dates) = c("months","start","end","szn")
} else {
colnames(all_dates) = c("szn","start","end")
}
library(dplyr)
library(lubridate)
library(tidyverse)
daily <- read.csv(paste0(filepath, "All_Variables_Summer2022_Fall2024_DAILY.csv"))
daily <- daily %>% select(-X) # %>% select(-X.1) # get rid of index columns
daily$Date <- as.POSIXct(daily$Date, format="%Y-%m-%d") # format dates
daily$fullname[daily$site == "BEO"] <- "BEO-BASE"
daily <- daily %>% filter(fullname == "TNHA-SA" | fullname == "TNHA-SC" | fullname == "SSMH-SB" | fullname == "SSMH-SA" | fullname == "BEO-BASE") %>% select(-c(winddirection)) %>% mutate(aspect = case_when(fullname == "TNHA-SC" | fullname == "SSMH-SB" ~ "North", fullname == "TNHA-SA" | fullname == "SSMH-SA" ~ "South", .default = "N/A")) %>% filter(grounddepth == "10cm") %>% filter(Date >= "2022-06-19") %>% na.omit() # %>% filter(windspeed >= 0) %>% na.omit() # create "aspect" column and filter for top depth of soil and start date of when we started collecting data
# note: the data before June 19, 2022 was estimated by our gap-filling script and should be disregarded due to extrapolation
=========================
=========================
Temporal Range: Season Vertical Spatial Range: 30-45 cm Horizontal Spatial Range: stations across site (TNHA, SSMH, BEO) –> Average Total Site –> North vs South (except for BEO)
pick_site <- function(cursite){
big_df <<- daily %>% filter(site == cursite)
if(szn == "Winter"){
big_df <<- big_df %>% select(-solar)
}
return(big_df)
}
pick_dates <- function(datemin, datemax, big_df){
pca_df <<- big_df %>% filter(Date >= datemin) %>% filter(Date < datemax)
# get rid of NAs
pca_df <<- na.omit(pca_df)
pca_df <<- unique(pca_df)
return(pca_df)
}
calc_pca <- function(pca_df){
tryCatch({ pca <<- prcomp(pca_df[,7:(ncol(pca_df)-1)], center=TRUE, scale.=TRUE) }, error = function(msg){
print(paste("There was an issue with making the PCA:", msg))
return(NA)
})
#take out variables
sd <- pca$sdev
loads <<- pca$rotation
rownames(loads) <<- colnames(pca_df[7:(ncol(pca_df)-1)])
scores <<- pca$x
var <- sd^2
varPercent <- var/sum(var) * 100
return(list("pca"=pca, "loads"=loads))
}
make_scree <- function(pca){
sd <- pca$sdev
var <- sd^2
varPercent <- var/sum(var) * 100
barplot(varPercent, xlab="PC", ylab="Percent Variance", names.arg=1:length(varPercent),
las=1, ylim=c(0, max(varPercent)), col="gray")
abline(h=1/ncol(pca_df[5:ncol(pca_df)])*100, col="red")
}
make_eigen <- function(pca){
eigenvectors <- pca$rotation
print("Eigenvectors (Loadings):")
print(eigenvectors)
print("Loadings Cutoff:")
sqrt(1/ncol(pca_df[5:ncol(pca_df)])) # cutoff for "important" loadings
# Access the eigenvalues (variances of the principal components)
eigenvalues <- (pca$sdev)^2
print("Eigenvalues:")
print(eigenvalues)
}
===============
===============
plotcounter <<- 0
make_pca <- function(pca_df, szn, yr, cursite){
if (pdf | exp_pdf) {
pdf(file = paste0(exportpath, "pca_", plotcounter, ".pdf"), # The directory you want to save the file in
width = 8, # The width of the plot in inches
height = 8) # The height of the plot in inches
plotcounter <<- plotcounter + 1
}
if (cursite == "BEO")
{
# SOUTH <<- pca_df$site == cursite
SOUTH <<- rep(TRUE, length(scores[,1]))
# n <- "BEO"
} else {
SOUTH <<- pca_df$site == cursite & pca_df$aspect == "South"
NORTH <<- pca_df$site == cursite & pca_df$aspect == "North"
s <- pca_df$fullname[SOUTH][1]
n <- pca_df$fullname[NORTH][1]
}
xmin = floor(min(scores[,1])*limNudge)
xmax = ceiling(max(scores[,1])*limNudge)
ymin = floor(min(scores[,2])*limNudge)
ymax = ceiling(max(scores[,2])*limNudge)
xlimit <- seq(xmin, xmax, 1)
ylimit <- seq(ymin, ymax, 1)
plot(scores[, 1], scores[, 2], xlab="Principal Component 1", ylab="Principal Component 2", type="n", asp=1,
las=1, xaxt='n', yaxt='n')
axis(side = 1, at=xlimit)
axis(side = 2, at=ylimit)
if (cursite == "BEO")
{
nvstext <- " "
} else {
nvstext <- " North v. South "
}
mindate = format(as.Date(min(pca_df$Date)), format="%B %d %Y")
maxdate = format(as.Date(max(pca_df$Date)), format="%B %d %Y")
title(paste0(szn, " ", yr," Principal Component Analysis:\n", site, nvstext, "\n(", mindate," - ", maxdate, ")"), adj=0.5)
points(scores[SOUTH, 1], scores[SOUTH, 2], pch=16, cex=1, col="mediumturquoise")
if(cursite != "BEO"){
points(scores[NORTH, 1], scores[NORTH, 2], pch=16, cex=1, col="salmon")
legend(x = "topright", # Position
legend = c(paste0(s, " (south)"), paste0(n, " (north)")), # Legend texts
col = c("mediumturquoise","salmon"),
pch = 19) #colors
} else{
legend(x = "topright", # Position
legend = "BEO", # Legend texts
col = "mediumturquoise",
pch = 19)
}
arrows(0, 0, loads[, 1]* scaling, loads[, 2]* scaling, length=0.1, angle=30, col="darkred", lwd=2)
arr1x = loads[1, 1]*scaling*textNudge
arr1y = loads[1, 2]*scaling*textNudge
if(arr1y < ymax / 2 & arr1y > ymin / 2)
{
arr1x = loads[1, 1]*scaling*(textNudge+(textAdj * length(rownames(loads)[1]))+0.3)
}
arr2x = loads[2, 1]*scaling*textNudge
arr2y = loads[2, 2]*scaling*textNudge
if(arr2y < ymax / 2 & arr2y > ymin / 2)
{
arr2x = loads[2, 1]*scaling*(textNudge+(textAdj * length(rownames(loads)[2])))
}
# check if any text is overlapping groundtemp text (arr1y)
arr_overlap = data.frame(arrow=1, x=arr1x, y=arr1y)
if(abs(arr1x-arr2x) < 1 & abs(arr1y-arr2y) < 0.8) {
arr_overlap = rbind(arr_overlap, data.frame(arrow=2, x=arr2x, y=arr2y))
}
if(nrow(loads) > 2){
arr3x = loads[3, 1]*scaling*(textNudge+0.2)
arr3y = loads[3, 2]*scaling*textNudge
if(arr3y < ymax / 2 & arr3y > ymin / 2)
{
arr3x = loads[3, 1]*scaling*(textNudge+(textAdj * length(rownames(loads)[3])))
}
if(abs(arr1x-arr3x) < 1 & abs(arr1y-arr3y) < 0.8) {
arr_overlap = rbind(arr_overlap, data.frame(arrow=3, x=arr3x, y=arr3y))
}
if(nrow(loads) > 3){
arr4x = loads[4, 1]*scaling*textNudge-0.2
arr4y = loads[4, 2]*scaling*textNudge
if(arr4y < ymax / 2 & arr4y > ymin / 2)
{
arr4x = loads[4, 1]*scaling*(textNudge+(textAdj * length(rownames(loads)[4])))
}
if(abs(arr1x-arr4x) < 1 & abs(arr1y-arr4y) < 0.8) {
arr_overlap = rbind(arr_overlap, data.frame(arrow=4, x=arr4x, y=arr4y))
}
if(nrow(loads) > 4){
arr5x = loads[5, 1]*scaling*textNudge
arr5y = loads[5, 2]*scaling*textNudge
if(arr5y < ymax / 2 & arr5y > ymin / 2)
{
arr5x = loads[5, 1]*scaling*(textNudge+(textAdj * length(rownames(loads)[5])))
}
if(abs(arr1x-arr5x) < 1 & abs(arr1y-arr5y) < 0.8) {
arr_overlap = rbind(arr_overlap, data.frame(arrow=5, x=arr5x, y=arr5y))
}
}
}
}
arr_overlap = arr_overlap[order(arr_overlap$y, decreasing=F),]
arr1y = arr_overlap$y[floor(length(arr_overlap$arrow)/2)] + ((which(arr_overlap$arrow == 1) - floor(length(arr_overlap$arrow)/2))*0.3)
if(2 %in% arr_overlap$arrow) {
arr2y = arr_overlap$y[floor(length(arr_overlap$arrow)/2)] + ((which(arr_overlap$arrow == 2) - floor(length(arr_overlap$arrow)/2))*0.3)
}
if(3 %in% arr_overlap$arrow) {
arr3y = arr_overlap$y[floor(length(arr_overlap$arrow)/2)] + ((which(arr_overlap$arrow == 3) - floor(length(arr_overlap$arrow)/2))*0.3)
}
if(4 %in% arr_overlap$arrow) {
arr4y = arr_overlap$y[floor(length(arr_overlap$arrow)/2)] +((which(arr_overlap$arrow == 4) - floor(length(arr_overlap$arrow)/2))*0.3)
}
if(5 %in% arr_overlap$arrow) {
arr5y = arr_overlap$y[floor(length(arr_overlap$arrow)/2)] + ((which(arr_overlap$arrow == 5) - floor(length(arr_overlap$arrow)/2))*0.3)
}
text(arr1x, arr1y, rownames(loads)[1], col="darkred", cex=1) # ground label
text(arr2x, arr2y, rownames(loads)[2], col="darkred", cex=1) # vwc label
if(nrow(loads) > 2){
text(arr3x, arr3y, rownames(loads)[3], col="darkred", cex=1) # airtemp label
if(nrow(loads)>3){
text(arr4x, arr4y, rownames(loads)[4], col="darkred", cex=1) # solar or wind label
if(nrow(loads)>4){
text(arr5x, arr5y, rownames(loads)[5], col="darkred", cex=1) # solar or wind label
}
}
}
if(pdf | exp_pdf) {
dev.off()
}
}
Adjust Settings for PCA Plots
# settings for pca plots
scaling <<- 2 # scaling the arrows
textNudge <<- 1.2 # nudge the arrow labels (added)
textAdj <<- 0.3 # adjust the text position based on the length of the label (multiplied)
limNudge <<- 1.3 # nudge the plot limits
exp_pdf <<- F
site = "TNHA"
i = 1
pca_output = list()
loads_output = data.frame(matrix(nrow = 0, ncol = 5))
colnames(loads_output) = c("PC1", "PC2", "PC3", "PC4", "PC5")
for(i in c(1:nrow(all_dates))){
# month <- all_dates$months[i]
startdate <- all_dates$start[i]
enddate <- all_dates$end[i]
szn <<- all_dates$szn[i]
yr <<- substr(all_dates$start[i], 1, 4)
sitecounter = 0
for(site in sites){
sitecounter = sitecounter + 1
big_df <- pick_site(site)
pca_df <- pick_dates(startdate, enddate, big_df)
if(nrow(pca_df) > 4){
p <- calc_pca(pca_df)
pca <- p$pca
loads <- p$loads
pca_output[((3*(i-1)) + sitecounter)] = p
loads_output = rbind(loads_output, loads)
if(scree == T){
make_scree(pca)
}
if(eigen == T){
make_eigen(pca)
}
make_pca(pca_df, szn, yr, site)
}
}
}
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.4769631 -0.2847556 -0.53037031 -0.4406209 0.4647376
## vwc 0.3842673 0.6801673 0.07271330 0.3938989 0.4788189
## airtemp 0.4661539 -0.4549751 -0.15075867 0.6914162 -0.2737037
## solar 0.5228761 0.3867197 -0.01725517 -0.3653658 -0.6657766
## windspeed 0.3662594 -0.3158042 0.83089963 -0.1978595 0.1912569
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.6753329 1.1252026 0.7405202 0.3336787 0.1252655
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.5552359 -0.131276923 0.1333380 0.186092654 -0.78871411
## vwc -0.1610482 0.856147077 0.4110895 0.249467837 0.09923162
## airtemp -0.4996351 -0.374966075 0.1294729 0.527951106 0.56059757
## solar -0.5200740 -0.007161492 0.2373128 -0.790134046 0.22100351
## windspeed 0.3816600 -0.330344833 0.8603173 -0.009546772 -0.07050501
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.94224356 1.09588522 0.60984272 0.26516785 0.08686064
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.5328296 -0.33727702 0.2583125 0.12159414 -0.72168299
## vwc -0.4280423 -0.42690457 0.3919685 -0.68733125 -0.09202593
## airtemp 0.5007696 -0.48336552 0.2261760 0.02616724 0.68098991
## solar 0.4393714 0.08152481 -0.6008789 -0.66153748 -0.04023928
## windspeed -0.2984209 -0.68096122 -0.6061553 0.27289936 -0.07306460
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.88933794 0.95473795 0.73742280 0.38748347 0.03101785
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.5143652 -0.38401347 -0.25954939 0.02100310 -0.72121780
## vwc 0.3683970 -0.61091463 0.07999256 0.69408596 0.05397096
## airtemp -0.4912730 -0.44499748 -0.27195710 -0.15251370 0.68074000
## solar -0.4420670 -0.04990138 0.89112359 0.08617129 0.02366266
## windspeed 0.4036580 -0.52801901 0.24119161 -0.69793812 -0.11386462
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.7449492 1.1441871 0.5762818 0.4076313 0.1269505
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.5650660 0.05204597 -0.32294343 0.20991356 0.72776057
## vwc -0.1785442 0.98009413 -0.07407387 0.03793655 0.02472549
## airtemp 0.5341150 0.07259460 -0.50097992 0.09683782 -0.67014382
## solar 0.4509233 0.13751466 0.31737555 -0.82261835 0.01815786
## windspeed -0.4002645 -0.11192164 -0.73383410 -0.51809131 0.14258597
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.74283793 0.94486591 0.76145594 0.51383781 0.03700241
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.5428285 0.1174772 -0.1063564 0.39180116 -0.725752352
## vwc -0.3997249 0.4121705 0.6950150 -0.43167234 0.030800767
## airtemp -0.5374196 0.1228137 -0.1293208 0.45570339 0.686809648
## solar -0.4563648 -0.2277775 -0.5426727 -0.66691912 0.023956050
## windspeed 0.2201557 0.8656494 -0.4409366 -0.08777326 -0.007311043
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.9516858 0.9801039 0.6164004 0.3435792 0.1082308
## [1] "There was an issue with making the PCA: Error in prcomp.default(pca_df[, 7:(ncol(pca_df) - 1)], center = TRUE, : cannot rescale a constant/zero column to unit variance\n"
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.5428285 0.1174772 -0.1063564 0.39180116 -0.725752352
## vwc -0.3997249 0.4121705 0.6950150 -0.43167234 0.030800767
## airtemp -0.5374196 0.1228137 -0.1293208 0.45570339 0.686809648
## solar -0.4563648 -0.2277775 -0.5426727 -0.66691912 0.023956050
## windspeed 0.2201557 0.8656494 -0.4409366 -0.08777326 -0.007311043
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.9516858 0.9801039 0.6164004 0.3435792 0.1082308
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.50244064 0.3261535 0.4022978 0.43958906 -0.5348787
## vwc -0.48802601 -0.4094477 -0.2921055 -0.54569955 -0.4594231
## airtemp -0.50077217 0.3772612 0.3034607 -0.46073103 0.5500361
## solar -0.50768501 -0.2596402 -0.4557189 0.53971037 0.4193756
## windspeed 0.02944777 0.7184967 -0.6730994 -0.07357372 -0.1562675
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.4732391 1.2769596 0.7316518 0.2891769 0.2289726
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.6125420 0.02409706 0.254845127 0.22734401 0.712446653
## vwc 0.3658603 -0.13608907 -0.919734390 0.04097674 0.005963305
## airtemp 0.6082260 -0.03909511 0.255300954 0.27174289 -0.699649892
## solar 0.2980378 0.64765270 -0.008764084 -0.69925021 -0.051882331
## windspeed 0.1793686 -0.74827579 0.154554929 -0.61954867 0.013507705
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.42490334 1.24762122 0.77007319 0.53412872 0.02327354
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.5988503 0.17595605 0.02939594 0.2923810 -0.72392473
## vwc -0.5964524 -0.02540663 0.17887710 0.4157313 0.66239681
## airtemp -0.4836251 -0.14781326 -0.61691383 -0.5949036 0.09881842
## solar -0.1401958 0.71258104 0.44834504 -0.5112544 0.10089119
## windspeed -0.1790944 -0.66239979 0.62092102 -0.3555130 -0.13122246
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.5453168 1.4275416 0.6342916 0.3726363 0.0202136
## [1] "There was an issue with making the PCA: Error in prcomp.default(pca_df[, 7:(ncol(pca_df) - 1)], center = TRUE, : cannot rescale a constant/zero column to unit variance\n"
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.5988503 0.17595605 0.02939594 0.2923810 -0.72392473
## vwc -0.5964524 -0.02540663 0.17887710 0.4157313 0.66239681
## airtemp -0.4836251 -0.14781326 -0.61691383 -0.5949036 0.09881842
## solar -0.1401958 0.71258104 0.44834504 -0.5112544 0.10089119
## windspeed -0.1790944 -0.66239979 0.62092102 -0.3555130 -0.13122246
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.5453168 1.4275416 0.6342916 0.3726363 0.0202136
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.30099677 -0.6437397 -0.21870427 -0.43582732 -0.50717172
## vwc 0.47977021 0.5505845 0.23844745 0.12829968 -0.62718360
## airtemp 0.49375797 -0.3218633 -0.24191377 0.75450070 0.15752312
## solar 0.65421961 0.1853790 -0.01210707 -0.47034390 0.56237121
## windspeed 0.08614673 -0.3801245 0.91468159 0.05566921 0.09133822
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 1.8198101 1.5685420 0.9048869 0.5938899 0.1128711
## [1] "There was an issue with making the PCA: Error in prcomp.default(pca_df[, 7:(ncol(pca_df) - 1)], center = TRUE, : cannot rescale a constant/zero column to unit variance\n"
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.30099677 -0.6437397 -0.21870427 -0.43582732 -0.50717172
## vwc 0.47977021 0.5505845 0.23844745 0.12829968 -0.62718360
## airtemp 0.49375797 -0.3218633 -0.24191377 0.75450070 0.15752312
## solar 0.65421961 0.1853790 -0.01210707 -0.47034390 0.56237121
## windspeed 0.08614673 -0.3801245 0.91468159 0.05566921 0.09133822
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 1.8198101 1.5685420 0.9048869 0.5938899 0.1128711
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.5445110 0.07028221 -0.31374755 0.3355470 -0.69823986
## vwc 0.5512011 -0.02944507 -0.27356715 0.3372258 0.71186383
## airtemp -0.3852612 -0.68678833 -0.06774361 0.6109275 -0.04554115
## solar -0.3360010 0.05516788 -0.90639203 -0.2480193 0.03161839
## windspeed 0.3719708 -0.72074385 -0.02424423 -0.5821864 -0.05135426
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.83636976 0.92768273 0.79630819 0.36877664 0.07086267
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.4422411 -0.49570595 0.20578643 0.71458641 0.075608073
## vwc 0.5499170 -0.07870712 -0.20930176 0.26563354 0.759623638
## airtemp 0.1457220 -0.84910433 0.03039559 -0.50675519 -0.007888788
## solar 0.5296577 -0.15199663 -0.36517978 0.39501611 -0.637938668
## windspeed -0.4474840 -0.06324281 -0.88292953 -0.07724331 0.101130460
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.8171237 1.2152950 0.5487713 0.2471169 0.1716931
## [1] "There was an issue with making the PCA: Error in prcomp.default(pca_df[, 7:(ncol(pca_df) - 1)], center = TRUE, : cannot rescale a constant/zero column to unit variance\n"
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.4422411 -0.49570595 0.20578643 0.71458641 0.075608073
## vwc 0.5499170 -0.07870712 -0.20930176 0.26563354 0.759623638
## airtemp 0.1457220 -0.84910433 0.03039559 -0.50675519 -0.007888788
## solar 0.5296577 -0.15199663 -0.36517978 0.39501611 -0.637938668
## windspeed -0.4474840 -0.06324281 -0.88292953 -0.07724331 0.101130460
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.8171237 1.2152950 0.5487713 0.2471169 0.1716931
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.56020925 -0.03595515 -0.39908518 0.6687051 0.2800667
## vwc -0.60394134 -0.06476337 0.03860959 -0.1609913 -0.7769502
## airtemp 0.04238186 0.72814782 0.49921452 0.4395645 -0.1599138
## solar 0.35842586 -0.61339660 0.26273194 0.5627316 -0.3310295
## windspeed -0.43721291 -0.29674618 0.72180129 -0.1305047 0.4275020
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.5256353 1.4741122 0.6986243 0.1912920 0.1103361
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.5430178 -0.1553506 -0.2674034 -0.3286703 0.708144851
## vwc 0.5480880 -0.1228474 -0.2337543 -0.3648166 -0.704823308
## airtemp 0.4568214 -0.4599796 0.2598659 0.7153736 -0.021053893
## solar 0.3324028 0.4249681 0.8086523 -0.2316999 0.036153463
## windspeed 0.2924958 0.7540528 -0.3903916 0.4398186 -0.002152882
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 3.04658399 1.04700474 0.71008573 0.18512090 0.01120464
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.58258982 -0.0415532 -0.1180185 -0.07321092 -0.79973384
## vwc 0.53425067 -0.0409141 0.0575969 0.78279394 0.31115671
## airtemp 0.48468848 -0.3424764 -0.4021858 -0.50862699 0.47679361
## solar 0.36356408 0.3705240 0.7618179 -0.35050737 0.16526076
## windspeed 0.08979729 0.8614066 -0.4905448 -0.01780363 0.09467848
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.6121834 1.0615388 0.7885400 0.3836917 0.1540462
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.4880598 0.23753616 -0.3715933 -0.2008195 -0.7259229
## vwc 0.4915024 0.05552798 0.1858094 -0.7185138 0.4522774
## airtemp 0.4510738 0.51920558 -0.1944036 0.5611708 0.4174357
## solar 0.3682902 -0.79447467 -0.4214282 0.1784834 0.1539945
## windspeed -0.4255794 0.19932082 -0.7823035 -0.3108705 0.2655452
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 3.2984339 0.7006120 0.5479068 0.2869112 0.1661361
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.5304454 0.16307251 -0.16082817 -0.6540073 0.48830707
## vwc -0.3626735 -0.57633347 0.41900328 -0.5960584 -0.07388059
## airtemp 0.5862635 -0.05310924 0.08398276 -0.1483825 -0.79019243
## solar 0.1867055 -0.75138163 -0.59986095 0.1798993 0.09148660
## windspeed -0.4566529 0.27175750 -0.65702686 -0.4032465 -0.35117517
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.4677107 1.1516739 0.6846642 0.4827404 0.2132109
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.6244708 0.10245069 -0.14613843 0.6447743 0.4030505
## vwc 0.6591067 0.01318784 0.06780400 -0.1690401 -0.7295427
## airtemp 0.2980969 -0.40682997 0.69691597 -0.3161435 0.3999863
## solar -0.1944242 -0.77937100 0.03474391 0.5105520 -0.3048107
## windspeed -0.2212512 0.46518829 0.69795929 0.4416802 -0.2289524
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.20963659 1.40435442 1.11336327 0.21917184 0.05347388
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.5079220 0.1577112 -0.2647199 0.1020310 0.7979069
## vwc -0.4140677 -0.5978955 -0.4771912 0.3492661 -0.3483830
## airtemp -0.4591138 0.3985558 -0.2843595 -0.6338820 -0.3843189
## solar -0.4401762 0.4408064 0.4553013 0.5667951 -0.2887538
## windspeed 0.4074588 0.5142870 -0.6434690 0.3801839 -0.1043745
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 3.55167097 0.70554577 0.45648730 0.23646805 0.04982791
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.5350523 -0.3095552 0.51946546 -0.07186236 0.58556471
## vwc 0.4030333 0.1631705 -0.57258529 -0.68028800 0.14245666
## airtemp 0.6593076 0.1075425 0.19915832 0.10009706 -0.70997512
## solar -0.1997769 -0.8011739 0.06326441 -0.43722492 -0.35077277
## windspeed 0.2769222 -0.4733983 -0.59886166 0.57520343 0.09855895
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.0409554 1.2000815 0.9657433 0.6865656 0.1066541
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.5761576 0.06584409 -0.2527034 -0.1384959 0.76201502
## vwc -0.5434132 -0.17356977 0.2960704 -0.6441212 -0.41475991
## airtemp -0.5000573 0.12955741 -0.5407717 0.4516794 -0.48652779
## solar -0.2864779 0.54065594 0.6876457 0.3892395 0.03546259
## windspeed -0.2015380 -0.81021239 0.2884316 0.4586993 0.09664595
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.74971721 1.19075915 0.84683468 0.17014019 0.04254877
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.5429699 0.060679133 -0.2863696 0.193382797 0.76295300
## vwc -0.1574413 0.958472259 0.2122171 -0.005984109 -0.10710407
## airtemp -0.4571830 0.005861624 -0.6618817 0.064221114 -0.59054011
## solar 0.4545890 0.226098929 -0.5808740 -0.590399585 0.23715363
## windspeed -0.5145178 -0.162769432 0.3121767 -0.780942547 -0.03810477
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.8253128 0.9705891 0.8121612 0.2409960 0.1509408
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.5802101 0.1191513 0.01252123 0.28953339 -0.75177976
## vwc -0.5602560 0.1126857 -0.10669549 0.50073226 0.64132557
## airtemp -0.4332548 0.4319265 0.36144412 -0.68882209 0.14356885
## solar 0.1931837 0.7277361 -0.65568527 -0.02016779 -0.05244315
## windspeed 0.3527602 0.5068970 0.65413628 0.43652605 -0.01290031
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.75906860 1.14000578 0.68155944 0.37837714 0.04098905
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.5492008 0.04982871 -0.22322918 0.49789544 0.63100276
## vwc -0.5148912 0.10274787 -0.08312946 -0.82993437 0.16919925
## airtemp -0.3174571 0.79778297 0.27054323 0.18861621 -0.39242016
## solar -0.4911713 -0.42661613 -0.36579121 0.15667428 -0.64683802
## windspeed 0.3020552 0.41048872 -0.85805675 -0.05644619 -0.02853264
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 1.9936405 1.0009576 0.8787744 0.6400946 0.4865328
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.5096269 -0.12176728 -0.2240929 -0.3978711 -0.71898132
## vwc -0.3727840 0.64884125 0.2025979 0.5868867 -0.23357065
## airtemp -0.5010050 -0.02179077 -0.6942478 0.1429526 0.49608838
## solar -0.4994571 0.13179059 0.5607081 -0.4868348 0.42634740
## windspeed -0.3175675 -0.73914421 0.3352057 0.4897132 -0.02519596
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 3.1479348 1.0768999 0.3134181 0.2453197 0.2164275
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.5435996 0.1265729 0.3643027 0.09393044 0.739553541
## vwc 0.5235828 -0.1038767 0.5406730 0.08654629 -0.644401405
## airtemp 0.4383863 0.3850272 -0.6126637 0.51120992 -0.151258507
## solar -0.4854048 0.2876283 0.4228147 0.70908019 0.009226008
## windspeed -0.0505984 0.8615178 0.1443165 -0.46856858 -0.121832402
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 3.093885436 1.274712347 0.461236707 0.165299393 0.004866118
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.54739002 -0.002446992 0.2389501 0.2910147 0.74737638
## vwc 0.54217384 -0.024947915 -0.1400634 -0.5202063 0.64435454
## airtemp -0.03070632 -0.943140453 0.2916036 -0.1433224 -0.06300171
## solar -0.49530394 0.228131663 0.2710824 -0.7798113 -0.14504714
## windspeed -0.40017850 -0.240444681 -0.8745094 -0.1266842 0.03504129
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 3.11247804 1.06095501 0.57079781 0.22805806 0.02771108
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.623809053 0.09103051 0.05459023 -0.3089924 -0.710013595
## vwc 0.619643020 0.12598023 0.06242704 -0.3179051 0.703712089
## airtemp 0.474419316 -0.32769114 -0.07478286 0.8134655 0.015042099
## solar -0.006047561 0.72164526 0.59723689 0.3494853 -0.018965536
## windspeed -0.042361924 -0.58965165 0.79425336 -0.1399785 0.009167043
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.406594798 1.178670076 0.913383469 0.493650893 0.007700765
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.5798930 -0.1518941 0.1211327 0.3045794 -0.7302126
## vwc 0.5502928 0.1929508 0.2220205 -0.4595806 -0.6320130
## airtemp -0.1618651 0.8760889 0.3842278 0.2197559 0.1017065
## solar -0.4448791 -0.1891245 0.5538754 -0.6423616 0.2165828
## windspeed -0.3698435 0.3693213 -0.6939919 -0.4848670 -0.1004826
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.65634605 1.02741644 0.80873637 0.45282076 0.05468038
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.4739740 0.2896665174 0.07907526 0.6535378 0.50801318
## vwc 0.4723966 -0.0006603275 -0.57182350 -0.5600270 0.36909167
## airtemp 0.4807359 0.1267592935 -0.32729664 0.2326430 -0.76914186
## solar 0.4535917 0.2490557322 0.72665330 -0.4365549 -0.11670757
## windspeed -0.3396139 0.9154213218 -0.17781137 -0.1206450 -0.02222815
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 4.01726398 0.63057674 0.22878578 0.06706301 0.05631049
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.6254906 -0.1544955 -0.26611713 -0.1458921 -0.7019899
## vwc 0.4336281 0.5853983 -0.11345234 0.6552779 0.1643622
## airtemp 0.6197744 -0.2860127 0.05395113 -0.3106493 0.6592896
## solar 0.1407735 -0.4208590 0.75510457 0.4543477 -0.1626216
## windspeed -0.1295793 -0.6119758 -0.58584691 0.4963784 0.1381545
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.0918050 1.2915631 1.1510972 0.3396615 0.1258731
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.6107006 -0.0006820838 0.06224163 -0.439953262 -0.65544748
## vwc 0.3456432 -0.6452255133 -0.28806171 -0.614166969 0.06351524
## airtemp -0.6024428 0.0967561854 -0.23342978 -0.257582116 0.71194302
## solar -0.3518653 -0.6189062193 -0.34420893 0.602398788 -0.10854406
## windspeed 0.1443224 0.4373521510 -0.86033550 0.002686019 -0.21842560
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.3310618 1.2059995 0.9654221 0.3679737 0.1295428
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.5607967 0.14427868 -0.2197043 -0.38591852 0.68373072
## vwc 0.3763691 0.32520166 0.8614985 0.08869721 -0.05043130
## airtemp 0.5724821 0.08732385 -0.3006043 -0.23862629 -0.71925887
## solar 0.4368149 -0.25383757 -0.1747055 0.83767668 0.11195992
## windspeed 0.1590924 -0.89519192 0.2977674 -0.29078336 -0.01003211
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.4363421 1.0233395 0.7292328 0.6337596 0.1773259
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.52675376 0.3922704 0.3014913 0.08987947 0.6853314
## vwc -0.44846728 -0.2925530 -0.5541254 -0.61998369 0.1478348
## airtemp -0.56142298 0.2304801 0.3467936 -0.17777566 -0.6926855
## solar 0.05696355 0.7608786 -0.6202828 0.12199470 -0.1348535
## windspeed -0.45051855 -0.3584401 -0.3114989 0.74903606 -0.1023091
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.4836006 1.2496715 0.6738422 0.4790596 0.1138261
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp -0.66994663 0.09165935 0.197715009 0.01751574 -0.70948717
## vwc -0.09483578 0.55932869 -0.684709810 -0.45575204 -0.04025109
## airtemp -0.60081266 0.32336908 0.251592286 0.08372537 0.68128406
## solar -0.26136761 -0.61852577 0.005053797 -0.72558292 0.15038858
## windspeed -0.33598929 -0.43773084 -0.654795413 0.50843167 0.09079156
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 1.8936224 1.5720798 0.8243134 0.5023784 0.2076059
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.58932834 0.2097269 -0.2162480 -0.2724052 -0.69838310
## vwc 0.26080082 -0.6990282 0.4179971 -0.5120069 0.08043524
## airtemp 0.58027697 0.2618748 -0.2559816 -0.1594340 0.70975660
## solar 0.03193059 0.5898472 0.7948620 -0.1382531 0.01188174
## windspeed -0.49692466 0.2255573 -0.2849263 -0.7868362 0.04353863
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 2.43034802 1.14226510 0.93683500 0.42896716 0.06158472
## Warning in pca_output[((3 * (i - 1)) + sitecounter)] <- p: number of items to
## replace is not a multiple of replacement length
## [1] "Eigenvectors (Loadings):"
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.687938134 0.09191809 -0.08572989 -0.1262126 0.70357157
## vwc 0.180799264 0.32395896 0.73659476 0.5648049 -0.02803230
## airtemp 0.690940097 -0.03236951 -0.07900384 -0.1345731 -0.70512585
## solar 0.129046560 -0.76534818 -0.15815460 0.6070843 0.06344257
## windspeed 0.001231985 -0.54753633 0.64716618 -0.5276406 0.05453257
## [1] "Loadings Cutoff:"
## [1] "Eigenvalues:"
## [1] 1.98988994 1.17003882 1.09164283 0.68907338 0.05935504
=============== # PCA Analysis ===============
Loadings (eigenvectors) of the principal components are the amount of variance captured for each variable Scalars (eigenvalues) are the leftover scalars after dimensionality reduction
$ = $ where \(\vec{v}\) is an eigenvector and \(\lambda\) is our eigenvalue scalar.
If we set our equation equal to zero such that $ A - = 0$ and solve for \(\lambda\).
TNHA South has more variation along PC1
TNHA North has more variation along PC2 than south, but generally has variance on both PCs
i = 1 # which loads you want to see
loads_output[c(1 + (5 * (i-1)):(5*i)-1),]
## PC1 PC2 PC3 PC4 PC5
## groundtemp 0.4769631 -0.2847556 -0.53037031 -0.4406209 0.4647376
## vwc 0.3842673 0.6801673 0.07271330 0.3938989 0.4788189
## airtemp 0.4661539 -0.4549751 -0.15075867 0.6914162 -0.2737037
## solar 0.5228761 0.3867197 -0.01725517 -0.3653658 -0.6657766
## windspeed 0.3662594 -0.3158042 0.83089963 -0.1978595 0.1912569